﻿// Open Source: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Project: YoProgramo.NET (http://code.google.com/p/yoprogramo/)
// Autor: Fabian Figueredo (info@fabianfigueredo.com.ar)
// Blog: blog.yoprogramo.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.ServiceLocation;
using YoProgramo.Domain.BusinessLogic.Service;
using YoProgramo.Domain.Core.Entities;
using YoProgramo.Domain.Core.Interfaces;

namespace YoProgramo.Domain.BusinessLogic.Extensions
{
    public static class TagExtension {
        public static int StoryCount(this ITag tag) {

            IStoryService storyService = ServiceLocator.Current.GetInstance<IStoryService>();

            var stories = (storyService.GetAllNotSpam()
                .Where(t => t.Tags.Contains((Tag)tag))).ToList();

            return stories.Count;
        }
    }
}